function range(i, k, step = 1) {
    const result = [];
    for (let n = i; n <= k; n += step) {
        result.push(n);
    }
    return result;
}

function scheduleHtmlParser(html) {

    course = []

    // table = window.document.getElementById("kbgrid_table_0")
    JSON.stringify(JSON.parse(html))
    row = table.getElementsByTagName("tr")
    for (var i = 2; i < row.length; i++) {

        col = row[i].getElementsByClassName("td_wrap")
        for (var j = 0; j < col.length; j++) {
            if (col[j].rowSpan != 1) {
                temp = col[j].getElementsByClassName("timetable_con text-left")
                for (var k = 0; k < temp.length; k++) {
                    col[j] = temp[k]
                    // console.log(col[j])
                    jsonobj = {}
                    courseaDetail = {}
                    start = ""
                    end = ""
                    last = ""
                    courseaDetail["name"] = col[j].getElementsByClassName("title")[0].getElementsByTagName("font")[0].textContent
                    courseaDetail["long"] = col[j].getElementsByTagName("p")[0].getElementsByTagName("font")[1].textContent
                    courseaDetail["className"] = col[j].getElementsByTagName("p")[3].getElementsByTagName("font")[1].textContent
                    courseaDetail["point"] = col[j].getElementsByTagName("p")[10].getElementsByTagName("font")[1].textContent

                    courseaDetail["position"] = col[j].getElementsByTagName("p")[1].getElementsByTagName("font")[1].textContent
                    courseaDetail["teacher"] = col[j].getElementsByTagName("p")[2].getElementsByTagName("font")[1].textContent
                    courseaDetail["sections"] = [(i + k * 2) - 1] //todo需要微调
                    courseaDetail["day"] = j + 1

                    // courseaDetail["weeks"] = 1
                    console.log(courseaDetail)
                    if (courseaDetail["long"].split(")")[1].split("-").length > 1) {
                        start = courseaDetail["long"].split(")")[1].split("-")[0]
                        end = courseaDetail["long"].split(")")[1].split("-")[1].split("周")[0]
                        console.log("start:" + start)
                        console.log("end:" + end)
                        courseaDetail["weeks"] = range(parseInt(start), parseInt(end))
                        if ((last = courseaDetail["long"].split(")")[1].split("-")[1].split("周")).length > 1) {
                            if (last[1].search("单") !== -1) {
                                console.log("单周课程")
                                courseaDetail["weeks"] = range(parseInt(start), parseInt(end), 2)
                            }
                            else if (last[1].search("双") !== -1) {
                                console.log("双周课程")
                                courseaDetail["weeks"] = range(parseInt(start), parseInt(end), 2)
                                // courseaDetail["weeks"] = last[1]
                            }

                        }
                    } else {
                        start = courseaDetail["long"].split(")")[1].split("周")[0]
                        end = courseaDetail["long"].split(")")[1].split("周")[0]
                        console.log("start:" + start)
                        console.log("end:" + end)
                        courseaDetail["weeks"] = [start]
                    }

                    courseaDetail["name"] += " 课程代码:" + courseaDetail["className"].split(")-")[1] + " 学分:" + courseaDetail["point"]


                    course.push(JSON.parse(JSON.stringify(courseaDetail)))
                }
            }



        }
    }
    return (course)
    console.log(course)

}